<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div class="modal-dialog ms-modal-dialog" style="width: 600px; margin-top: 100px;">
  <div class="modal-content">

    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
      <h4 class="modal-title">添加供方</h4>
    </div>

    <form action="${ctx.host}/appraisals/${appraisal.id}/results" method="POST" data-validate="true" class="form-horizontal ms-form modal-search-form" role="form">

      <c:choose>
        <c:when test="${appraisal.target.vendor}">
          <input type="hidden" name="target" value="vendor" />      
        </c:when>
        <c:otherwise>
          <input type="hidden" name="target" value="supplier" />
        </c:otherwise>
      </c:choose>

      <div class="modal-body">
        <div style="max-height: 350px; width: 100%; overflow-y: scroll;">
          <table class="table table-hover ms-table" style="font-size: 11px;">
            <thead>
              <tr>
                <th class="select">请选择</th>
                <th>代码</th>
                <th>简称</th>
                <th>全称</th>
              </tr>
            </thead>
  
            <tbody>
              <c:forEach var="supplier" items="${suppliers}">
                <tr>
                  <td>
                    <c:choose>
                      <c:when test="${checkedSuppliers.contains(supplier.idString)}">
                        <span class="glyphicon glyphicon-ok"></span>
                      </c:when>
                      <c:otherwise>
                        <input type="checkbox" name="supplierIds" value="${supplier.id}">
                      </c:otherwise>
                    </c:choose>
                  </td>
                  <td>${supplier.code}</td>
                  <td>${supplier.shortName}</td>
                  <td>${supplier.name}</td>
                </tr>
              </c:forEach>
            </tbody>
          </table>
        </div>
      </div>

      <div class="modal-footer ms-modal-footer">
        <button type="submit" class="btn ms-btn btn-primary">确定</button>
        <button type="button" class="btn ms-btn ms-btn-gary" data-dismiss="modal">取消</button>
      </div>

    </form>
  </div>
</div>

<script type="text/javascript">
  $(document).ready(function () {

    $('select[name="supplier"]').select2({
      theme: "classic",
      placeholder: '请选择供方',
      minimumResultsForSearch: -1,
      allowClear: true,
    });

  })
</script>